package cn.stronglink.assetmanage.business.inventory.view.goods;

import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.stronglink.assetmanage.R;
import cn.stronglink.assetmanage.entity.InventoryDetail;
import cn.stronglink.assetmanage.utils.ToastUtil;

/**
 * Created by yuzhantao on 2018/6/23.
 */

public class GoodsDetailEditView {
    private Fragment fragment;
    @BindView(R.id.tv_inventory_asset_name)
    EditText tv_inventory_asset_name;
    @BindView(R.id.tv_inventory_sn_no)
    EditText tv_inventory_sn_no;
    @BindView(R.id.tv_inventory_rfid_no)
    EditText tv_inventory_rfid_no;
    @BindView(R.id.tv_inventory_goods_detail_edit_asset_class)
    Spinner tv_inventory_asset_class;
    @BindView(R.id.sp_inventory_brand_name)
    Spinner sp_inventory_brand_name;
    @BindView(R.id.sp_inventory_location)
    Spinner sp_inventory_location;
    @BindView(R.id.tv_inventory_model_name)
    Spinner tv_inventory_model_name;
    private InventoryDetail inventoryDetail;

    public GoodsDetailEditView(Fragment fragment, View view) {
        this.fragment = fragment;
        ButterKnife.bind(this, view);
    }

    /**
     * 设置资产信息
     *
     * @param inventoryDetail
     */
    public void showAssetDetail(InventoryDetail inventoryDetail) {
        tv_inventory_asset_name.setText(inventoryDetail.getAssetName());
        tv_inventory_sn_no.setText(inventoryDetail.getAssetNo());
        tv_inventory_rfid_no.setText(inventoryDetail.getRfidNo());
    }

    public InventoryDetail saveAssetDetail(InventoryDetail preInventoryDetail) {
        inventoryDetail.setAssetName(tv_inventory_asset_name.getText().toString());
        inventoryDetail.setAssetNo(tv_inventory_sn_no.getText().toString());
        inventoryDetail.setRfidNo(tv_inventory_rfid_no.getText().toString());
        if (preInventoryDetail != null) {
            inventoryDetail.setBrandName(preInventoryDetail.getRoomName());
            inventoryDetail.setEndUser(preInventoryDetail.getBrandName());
            inventoryDetail.setRoomName(preInventoryDetail.getTypeName());
            inventoryDetail.setDatacenterId_(preInventoryDetail.getTypeName());
            inventoryDetail.setManageBranchId_(preInventoryDetail.getTypeName());
        }
        return inventoryDetail;
    }

    public void showProgressDialog(String msg) {

    }

    public void hideProgressDialog() {

    }

    public void showToast(String msg) {
        ToastUtil.toastShort(msg);
    }

}
